﻿using FluentNHibernate.Mapping;
using TimeTracker.Core.Domain.Entities;

namespace TimeTracker.Core.Domain.Mappings
{
    public class RadnikMappings : ClassMap<Radnik>
    {
        public RadnikMappings()
        {
            Table("Radnik");

            Id(x => x.RadnikId).GeneratedBy.Identity();
            Map(x => x.Ime);
            Map(x => x.Prezime);
            Map(x => x.Email);

            References(x => x.OrganizacionaSema)
                .ForeignKey("Id")
                .Column("OrganizacionaSemaId");

            HasMany(x => x.UnosiVremena)
                .Inverse()
                .AsBag()
                .Cascade.AllDeleteOrphan()
                .KeyColumn("UnosVremenaId");
        }
    }
}
